package com.ai.ly.goodsautocat.common;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;

import com.ai.ly.goodsautocat.util.FileUtil;

public class AreaNameDict {

    //字典，key=单词，value=是在字典中第几个单词（从1开始）
    private static Map<String, Object> dictMap=new HashMap<>();
    
    String filePath="data\\原始数据\\地名.txt";
    
    private AreaNameDict() {
        try {
            File file=FileUtil.getFileInSys(filePath);
            BufferedReader e = new BufferedReader(new FileReader(file));
            for (String lineContent = e.readLine(); lineContent != null; lineContent = e.readLine()) {
                dictMap.put(lineContent, Constants.DEFAULT_OBJECT);
            }
            e.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    private static AreaNameDict instance=new AreaNameDict();
    
    public static AreaNameDict getInstance() {
        return instance;
    }
    
    /**
     * 是否是一个地名
     * @param word
     * @return
     * @author liangyi
     */
    public static boolean isAreaName(String word) {
        return dictMap.get(word)!=null;
    }
    
}
